﻿/**
 *	html/monitor/center/scene/panel_switch.js
 *
 *	(C) 2014 Yuanjj
 *
 * 	history:
 * 		2014-07-21			create the file
 */

/**
 *	create the switch panel
 *
 *	@panel_center		[in] the center panel object
 *	@showflag			[in] the show flag ( "show" or "hide" )
 *
 *	return
 *		void
 */
function create_switch_panel( panel_center, showflag )
{
    var panel = Ext.create
    ("Ext.panel.Panel",{
         id:"panel_c_switch",
         layout:"vbox",
         flex:1,
         width:"100%",
         listeners:{ afterrender:_create_switch_component }
    });

    if ( "show" === showflag ) panel.show();
    else panel.hide();

    panel_center.add_subpanel( panel );
}

/**
 *	create the components for switch
 *
 *	@panel_c_switch			[in] the switch panel object
 */
function _create_switch_component( panel_c_switch )
{
    var switch_top_bar	= _create_switch_top_bar();
    var switch_grid		= _create_switch_grid();

    panel_c_switch.add( switch_top_bar );
    panel_c_switch.add( switch_grid );
}

function _create_switch_top_bar()
{
    var switch_top_bar = Ext.create
    ("Ext.toolbar.Toolbar",{ id:"switch_top_bar", width:"100%", height:30, });

    /*
    var top_bar_combox 			= create_form_field_combobox( alarm_top_bar, "通道类型", 50, 150, g_tunnel_type, "type", "local", 60, "serial", 0 )
    var top_bar_search_button 	= create_form_field_button( alarm_top_bar, "查询", on_search_alarm );
    */

    switch_top_bar.add(
        {xtype:"tbspacer", width:10 },
        {id:"pswitch_tunnel_type_combox", xtype:"combobox",	fieldLabel:"通道类型", labelWidth:50, width:200,
            queryMode:"local", store:g_tunnel_type, valueField:"serial", value:0, displayField:"type"},
        {xtype:"tbspacer", width:10 },
        {xtype:"button", text:"查询", frame:true, handler:on_search_switch_option, width:60}
    );

    return switch_top_bar;

}

var g_switch_grid;
function _create_switch_grid()
{
    g_switch_grid = Ext.create
    ("Ext.grid.Panel",{
         id:"ptunnel_tunnel_grid", width:"100%", flex:1, store:g_tunnel,
         selType:"rowmodel", multiSelect:true,
         columns:[
             {header:"序号", xtype:"rownumberer", width:50, align:"center"},
             {header:"主机编号", width:150, dataIndex:"host", align:"center"},
             {header:"通道名称", width:150, dataIndex:"name", align:"center"},
             {header:"通道类型", width:100, dataIndex:"type", align:"center"},
             {header:"通道编号", width:100, dataIndex:"number", align:"center"},
             {header:"备注说明", width:200, dataIndex:"remark"},
         ]
    });

    return g_switch_grid;
}

function on_search_switch_option()
{

}
